package org.yefei.homeworkday24;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

public class Six {
	public static void main(String[] args) {
		OutputStream o = null;
		try {
			o = new FileOutputStream("F:\\叶飞io测试\\data.txt");
			int k = 0, j = 0, i = 0;
			for (i = 2; i <= 10000; i++) {
				for (j = 2; j < i; j++) {
					if (i % j == 0)
						break;
				}
				if (j >= i) {
					System.out.print(i + "  ");
					k++;
					String s = i + " ";
					byte[] b = s.getBytes();
					o.write(b);
					if (k % 10 == 0) {
						o.write('\n');
						System.out.println();
					}

				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (o != null)
				try {
					o.close();
				} catch (IOException e) {
					e.printStackTrace();
				}

		}
	}
}
